import unittest

import sudokum


class CheckTest(unittest.TestCase):
    def test_check_true(self):
        s = [[1, 2, 8, 5, 4, 7, 6, 9, 3],
             [6, 3, 7, 9, 8, 1, 5, 2, 4],
             [4, 9, 5, 6, 3, 2, 7, 1, 8],
             [2, 1, 3, 7, 9, 4, 8, 5, 6],
             [5, 7, 4, 1, 6, 8, 9, 3, 2],
             [9, 8, 6, 3, 2, 5, 4, 7, 1],
             [3, 5, 1, 4, 7, 6, 2, 8, 9],
             [7, 4, 2, 8, 1, 9, 3, 6, 5],
             [8, 6, 9, 2, 5, 3, 1, 4, 7]]
        self.assertTrue(sudokum.check(s)[0])

    def test_false_row(self):
        s = [[1, 2, 8, 5, 4, 7, 6, 9, 3],
             [6, 3, 7, 9, 8, 1, 5, 2, 4],
             [4, 9, 3, 6, 3, 2, 7, 1, 8],
             [2, 1, 5, 7, 9, 4, 8, 5, 6],
             [5, 7, 4, 1, 6, 8, 9, 3, 2],
             [9, 8, 6, 3, 2, 5, 4, 7, 1],
             [3, 5, 1, 4, 7, 6, 2, 8, 9],
             [7, 4, 2, 8, 1, 9, 3, 6, 5],
             [8, 6, 9, 2, 5, 3, 1, 4, 7]]
        self.assertFalse(sudokum.check(s)[0])

    def test_false_col(self):
        s = [[1, 2, 8, 5, 4, 7, 6, 9, 3],
             [6, 3, 7, 9, 8, 1, 5, 2, 4],
             [4, 9, 5, 6, 3, 2, 7, 1, 8],
             [2, 3, 1, 7, 9, 4, 8, 5, 6],
             [5, 7, 4, 1, 6, 8, 9, 3, 2],
             [9, 8, 6, 3, 2, 5, 4, 7, 1],
             [3, 5, 1, 4, 7, 6, 2, 8, 9],
             [7, 4, 2, 8, 1, 9, 3, 6, 5],
             [8, 6, 9, 2, 5, 3, 1, 4, 7]]
        self.assertFalse(sudokum.check(s)[0])

    def test_false_sub(self):
        s = [[1, 2, 8, 5, 4, 7, 6, 9, 3],
             [6, 3, 7, 9, 8, 1, 5, 2, 4],
             [4, 9, 5, 6, 3, 2, 7, 1, 8],
             [7, 1, 3, 7, 9, 4, 8, 5, 6],
             [5, 2, 4, 1, 6, 8, 9, 3, 2],
             [9, 8, 6, 3, 2, 5, 4, 7, 1],
             [3, 5, 1, 4, 7, 6, 2, 8, 9],
             [7, 4, 2, 8, 1, 9, 3, 6, 5],
             [8, 6, 9, 2, 5, 3, 1, 4, 7]]
        self.assertFalse(sudokum.check(s)[0])
